USE [Tranco]
GO

/****** Object:  Table [dbo].[tblSchedule]    Script Date: 12/5/2013 10:19:03 PM ******/
SET ANSI_NULLS ON
GO

SET QUOTED_IDENTIFIER ON
GO

CREATE TABLE [dbo].[tblSchedule](
	[scheduleId] [bigint] IDENTITY(1,1) NOT NULL,
	[gatewayId] [int] NULL,
	[numberBikeId] [int] NULL,
	[content] [nvarchar](max) NULL,
	[ownerId] [int] NULL,
	[startDate] [int] NULL,
	[endDate] [int] NULL,
	[numberCont] [int] NULL,
	CONSTRAINT [PK_tblSchedule] PRIMARY KEY NONCLUSTERED 
	(
		[scheduleId] ASC
	)WITH (PAD_INDEX = OFF, STATISTICS_NORECOMPUTE = OFF, IGNORE_DUP_KEY = OFF, ALLOW_ROW_LOCKS = ON, ALLOW_PAGE_LOCKS = ON) ON [PRIMARY]
	) ON PartionScheme_DateKey([startDate])
GO
CREATE CLUSTERED INDEX CI_tblSchedule_startDate ON [dbo].[tblSchedule]([scheduleId],[startDate]) ON PartionScheme_DateKey([startDate])
GO


ALTER TABLE [dbo].[tblSchedule] CHECK CONSTRAINT [FK_tblSchedule_tblDate1]
GO

ALTER TABLE [dbo].[tblSchedule]  WITH CHECK ADD  CONSTRAINT [FK_tblSchedule_tblDate2] FOREIGN KEY([endDate])
REFERENCES [dbo].[tblDate] ([DateKey])
GO

ALTER TABLE [dbo].[tblSchedule] CHECK CONSTRAINT [FK_tblSchedule_tblDate2]
GO

ALTER TABLE [dbo].[tblSchedule]  WITH CHECK ADD  CONSTRAINT [FK_tblSchedule_tblGateway] FOREIGN KEY([gatewayId])
REFERENCES [dbo].[tblGateway] ([gatewayId])
GO

ALTER TABLE [dbo].[tblSchedule] CHECK CONSTRAINT [FK_tblSchedule_tblGateway]
GO

ALTER TABLE [dbo].[tblSchedule]  WITH CHECK ADD  CONSTRAINT [FK_tblSchedule_tblNumberBike] FOREIGN KEY([numberBikeId])
REFERENCES [dbo].[tblNumberBike] ([numberBikeId])
GO

ALTER TABLE [dbo].[tblSchedule] CHECK CONSTRAINT [FK_tblSchedule_tblNumberBike]
GO

ALTER TABLE [dbo].[tblSchedule]  WITH CHECK ADD  CONSTRAINT [FK_tblSchedule_tblOwner] FOREIGN KEY([ownerId])
REFERENCES [dbo].[tblOwner] ([ownerId])
GO

ALTER TABLE [dbo].[tblSchedule] CHECK CONSTRAINT [FK_tblSchedule_tblOwner]
GO
